import java.io.FileNotFoundException;
import java.io.IOException;

/**
 *
 */
public class Interview {

    private static void two(){
        int i = Integer.MAX_VALUE;
        System.out.println((i+1));
        System.out.println((i+1)<i);
        System.out.println("2. 存在一个i, 使得(i+1)<i");
    }

    private static void seven() {
        try{
            if(true){
                throw new IOException();
            }
        }catch (FileNotFoundException e){
            System.out.print("FileNotFoundException!");
        }catch (IOException e){
            System.out.print("IOException!");
        }catch (Exception e){
            System.out.print("Exception!");
        }

    }

    private static class StringExample1{
        String str = new String("good");
        char[] ch = {'a', 'b', 'c'};
        public void change(String str, char[] ch){
            str = "test ok";
            ch[0] = 'g';
        }

        public static void main(String[] args) {
            StringExample1 ex = new StringExample1();
            ex.change(ex.str, ex.ch);
            System.out.print(ex.str+" and ");
            System.out.print(ex.ch);
            System.out.println();
        }
    }

    private static class StringExample2{
        public static void change(String str){
            str = "welcome";
        }

        public static void main(String[] args) {
            String str = "1234";
            change(str);
            System.out.println(str);
        }
    }


    /**
     *
             for(int i=0;i<2;i++){

             }
             先执行 int i = 0;
             然后 判断 i<2
             然后执行函数体
             最后执行i++
             然后轮回到判断i<2
     */
    private static class ForLoop{
        static boolean foo(char c){
            System.out.print(c);
            return true;
        }

        public static void main(String[] args) {
            int i=0;
            for(foo('A');foo('B')&&(i<2);foo('C')){
                i++;
                foo('D');
            }
            System.out.println();
        }
    }

    private static class HelloA{
        public HelloA(){
            System.out.println("HelloA");
        }

        { System.out.println("I'm A class"); }

        static {
            System.out.println("static A");
        }
    }
    private static class HelloB extends HelloA{
        public HelloB(){
            System.out.println("HelloB");
        }

        { System.out.println("I'm B class"); }

        static {
            System.out.println("static B");
        }

        public static void main(String[] args) {
            System.out.println("main start");
            new HelloB();
            System.out.println("--------------------");
            new HelloB();
            System.out.println("main end");
        }
    }

    public static void main(String[] args) {
//        Interview.two();
//        Interview.seven();
//
//        StringExample1.main(null);
//        StringExample2.main(null);
//        ForLoop.main(null);
        HelloB.main(null);
    }
}
